import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class test {
    public static char[][][] allFloor = new char[10][7][10];//用三维数组储存所有楼层信息
    public static int SPEED = 1000;

    public static void main(String[] args) throws InterruptedException, IOException {
        floorArray.initArray(allFloor, ' ');
        floorArray.designArray(allFloor);
        char[][] res = new char[7][10];
        while (true) {
            System.out.println("输入当前楼层（按#退出系统）");
            Scanner scanner = new Scanner(System.in);
            String srcFloor_ = scanner.next();
            if("#".equals(srcFloor_)) {
                break;
            }
            int srcFloor = Integer.parseInt(srcFloor_);
            System.out.println("上|下");
            String direction = scanner.next();
            System.out.println("输入到达楼层");
            int desFloor = scanner.nextInt();
            int preFloor = srcFloor;
            while (("上".equals(direction) && preFloor != desFloor + 1)
                    || ("下".equals(direction) && preFloor != desFloor - 1)) {
                System.out.println("当前楼层为：");
                if (preFloor > 9) {
                    res = mergehotizontally(allFloor[preFloor / 10], allFloor[preFloor % 10]);
                    floorArray.print(res);
                    Thread.sleep(SPEED);
                    clearScreen();
                    if ("上".equals(direction)) {
                        preFloor++;
                    } else {
                        preFloor--;
                    }
                } else {
                    if ("上".equals(direction)) {
                        floorArray.print(allFloor[preFloor]);
                        preFloor++;
                        Thread.sleep(SPEED);
                        clearScreen();

                    }
                    if ("下".equals(direction)) {
                        floorArray.print(allFloor[preFloor]);
                        preFloor--;
                        Thread.sleep(SPEED);
                        clearScreen();

                    }
                }
            }
        }
        System.out.println("欢迎下次使用，再见。");

    }

    public static void clearScreen() {
        for (int i = 0; i < 50; i++) {
            System.out.println();
        }
    }

    public static char[][] mergehotizontally(char[][] arr1, char[][] arr2) {
        if (arr1 == null || arr1.length == 0) {
            return arr2;
        }
        if (arr2 == null || arr2.length == 0) {
            return arr1;
        }
        if (arr1.length != arr2.length) {
            throw new IllegalArgumentException("数组行数不一致，无法合并！");
        }
        int rows = arr1.length;
        int cols1 = arr1[0].length;
        int cols2 = arr2[0].length;
        int i = cols1 + cols2;
        char[][] res = new char[rows][cols1 + cols2];
        for (int j = 0; j < rows; j++) {
            if (arr1[j].length != cols1 || arr2[j].length != cols2) {
                throw new IllegalArgumentException("数组每行的列数必须相同才能合并！");
            }
            System.arraycopy(arr1[j], 0, res[j], 0, cols1);
            System.arraycopy(arr2[j], 0, res[j], cols1, cols2);

        }
        return res;

    }


}

